﻿using System;
using System.Globalization;

namespace Base.Common.Converters
{
    public class IsTypeConverter:ConverterBase
    {
        /// <summary>
        /// 类型
        /// </summary>
        public Type ValueType { get; set; }

        /// <summary>
        /// 是否反转
        /// </summary>
        public bool Invert { get; set; }

        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (ValueType.IsInstanceOfType(value))
                return !Invert;
            return Invert;
        }

        public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}
